package me.xiaosiqi.syt.cmn.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.xiaosiqi.syt.common.result.Result;
import me.xiaosiqi.syt.vo.user.LoginVo;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xiaosiqi
 * @date 2022/2/12 18:44
 */

@Api(tags = "用户管理")
@CrossOrigin
@RestController
@RequestMapping("/admin/hosp/user")
public class UserController {

    @ApiOperation("用户登录")
    @PostMapping("login")
    public Result login(@RequestBody LoginVo loginVo) {
        Map<String,String> map =new HashMap<>();
        map.put("token","admin-token");
        return Result.ok(map);
    }

    @ApiOperation("获取用户信息")
    @GetMapping("info")
    public Result info(@RequestParam String token) {
        if (token==null){
            return Result.fail();
        }
        Map<String,Object> map =new HashMap<>();
        map.put("roles",new String[]{"admin"});
        map.put("introduction","I am a super administrator");
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("name","xiaosiqi");
        return Result.ok(map);
    }

    @ApiOperation("用户登出")
    @PostMapping("logout")
    public Result logout() {
        return Result.ok();
    }

}
